﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace FySystem.Data.OrmA.Attributes
{
    /// <summary>
    /// 数据库字段类型
    /// </summary>
    public enum DbFieldTypes
    {
        Default=0,
        Json=1
    };

    /// <summary>
    /// 字段特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property,AllowMultiple =true)]
    public class FyColumnAttribute:Attribute
    {
        /// <summary>
        /// 映射的表字段，如果为空，则映射为实体属性同名字段
        /// </summary>
        public string MappingColumn { get; set; }

        /// <summary>
        /// 数据库字段类型
        /// </summary>
        public DbFieldTypes DbFieldType { get; set; } = DbFieldTypes.Default;

        public object TestType { get; set; }

        /// <summary>
        /// 是否为主键
        /// </summary>
        internal bool IsPrimaryKey { get; set; } = false;

        public FyColumnAttribute(DbFieldTypes dbFieldType = DbFieldTypes.Default, object DbType=null)
        {
            DbFieldType = dbFieldType;
        }

        public FyColumnAttribute(string column)
        {
            MappingColumn = column;
        }

        public FyColumnAttribute(DbFieldTypes dbFieldType,string column)
        {
            DbFieldType = dbFieldType;
            MappingColumn = column;
        }
    }
}
